home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / lh211src.zip / HUF_.ASM < prev    next >
Assembly Source File  |  1991-03-03  |  14KB  |  849 lines

  1. ;***********************************************
  2. ;    huf_.asm -- new static Huffman
  3. ;***********************************************
  4.             page    0, 128
  5.  
  6. include    amscls.inc
  7. $_init    GEN
  8.  
  9. NC        =    (200h - 2)
  10. CBIT    =    9
  11.  
  12. NP        =    14
  13. NT        =    19
  14. PBIT    =    4
  15. TBIT    =    5
  16. ;NPT    =    080h
  17.  
  18. CGROUP    group    TEXT
  19. DGROUP    group    DATA, BSS
  20.  
  21. TEXT    segment    public byte 'CODE'
  22. extrn    fillbuf_:near
  23. extrn    getbits_:near
  24. extrn    init_getbits_:near
  25. extrn    init_putbits_:near
  26. extrn    make_table_:near
  27. extrn    make_tree_:near
  28. extrn    putbits_:near
  29. extrn    putcode_:near
  30. TEXT    ends
  31.  
  32. DATA    segment    public word 'DATA'
  33. DATA    ends
  34.  
  35. BSS        segment    public word 'DATA'
  36. buf_            dd        1 dup (?)
  37. buf_limit_        dw        1 dup (?)
  38. blocksize_        dw        1 dup (?)
  39. output_pos_        dd        1 dup (?)
  40. cpos_            dw        1 dup (?)
  41. output_mask_    db        1 dup (?)
  42. BSS        ends
  43.  
  44. extrn    c_freq_:word
  45. extrn    p_freq_:word
  46. extrn    t_freq_:word
  47. extrn    left_:word
  48. extrn    right_:word
  49. extrn    c_table_:word
  50. extrn    c_code_:word
  51. extrn    pt_table_:word
  52. extrn    pt_code_:word
  53. extrn    c_len_:byte
  54. extrn    pt_len_:byte
  55.  
  56. public    buf_
  57. public    buf_limit_
  58.  
  59. extrn    bitbuf_:word
  60. extrn    unpackable_:word
  61.  
  62. assume    cs:CGROUP, ds:DGROUP
  63.  
  64. TEXT    segment    public byte 'CODE'
  65. ;
  66. ;    static void count_t_freq(void)
  67. ;
  68.  
  69. ;public    count_t_freq_
  70. count_t_freq_    proc    near
  71.     push    cx
  72.     push    si
  73.     push    di
  74.     cld
  75.     push    ds
  76.     pop        es
  77.     mov        cx, NT
  78.     mov        di, offset DGROUP:t_freq_
  79.     xor        ax, ax
  80.     rep        stosw
  81.     mov        cx, NC
  82.     mov        di, offset DGROUP:c_len_[NC - 1]
  83.     std
  84.     repe    scasb
  85.     cld
  86.     inc        di
  87.     mov        si, di
  88.     mov        di, offset DGROUP:c_len_
  89.     $_do
  90.         mov        bl, [di]
  91.         inc        di
  92.         $_if <or bl, bl>, Z
  93.             mov        cx, -1
  94.             repe    scasb
  95.             dec        di
  96.             not        cx
  97.             $_switch
  98.             $_case <cmp cx, 2>, BE
  99.                 add        t_freq_[0 * 2], cx
  100.                 $_break
  101.             $_case <cmp cx, 19>, BE
  102.                 $_if , E
  103.                     inc        t_freq_[0 * 2]
  104.                 $_endif
  105.                 inc        t_freq_[1 * 2]
  106.                 $_break
  107.             $_default
  108.                 inc        t_freq_[2 * 2]
  109.             $_endswitch
  110.         $_else
  111.             xor        bh, bh
  112.             shl        bx, 1
  113.             inc        t_freq_[bx + 2 * 2]
  114.         $_endif
  115.     $_until <cmp di, si>, A
  116.     pop        di
  117.     pop        si
  118.     pop        cx
  119.     ret
  120. count_t_freq_    endp
  121.  
  122. ;
  123. ;    static void write_pt_len(short n, short nbit, short i_special)
  124. ;
  125.  
  126. ;public    write_pt_len_
  127. write_pt_len_    proc    near
  128.     push    cx
  129.     push    si
  130.     push    di
  131.  
  132.     push    cx                    ; i_special
  133.     push    bx                    ; nbit
  134.     mov        si, offset DGROUP:pt_len_
  135.     lea        di, [si - 1]
  136.     add        di, ax
  137.     mov        cx, ax
  138.     inc        cx
  139.     xor        al, al
  140.     std
  141.     repe    scasb
  142.     cld
  143.     mov        bx, cx
  144.     pop        ax                    ; nbit
  145.     call    putbits_
  146.     inc        di
  147.     pop        cx                    ; i_special
  148.     add        cx, si
  149.     $_do
  150.         xor        bh, bh
  151.         mov        bl, [si]
  152.         inc        si
  153.         $_if <cmp bl, 6>, BE
  154.             mov        al, 3
  155.         $_else
  156.             mov        ax, bx
  157.             sub        ax, 3
  158.             mov        bx, 0fffeh
  159.         $_endif
  160.         call    putbits_
  161.         $_if <cmp si, cx>, E
  162.             $_while <cmp si, offset DGROUP:pt_len_ + 6>, B, AND
  163.             $_c     <cmp byte ptr [si], 0>, E
  164.                 inc        si
  165.             $_enddo
  166.  
  167.             mov        al, 2
  168.             mov        bx, si
  169.             sub        bx, offset DGROUP:pt_len_ + 3;
  170.             call    putbits_
  171.         $_endif
  172.     $_until <cmp si, di>, A
  173.  
  174.     pop        di
  175.     pop        si
  176.     pop        cx
  177.     ret
  178. write_pt_len_    endp
  179.  
  180. ;
  181. ;    static void write_c_len(void)
  182. ;
  183.  
  184. ;public    write_c_len_
  185. write_c_len_    proc    near
  186.     push    cx
  187.     push    si
  188.     push    di
  189.     mov        di, offset DGROUP:c_len_ + NC - 1
  190.     mov        cx, NC + 1
  191.     xor        al, al
  192.     std
  193.     repe    scasb
  194.     cld
  195.     inc        di
  196.     mov        si, di
  197.     mov        di, offset DGROUP:c_len_
  198.     mov        bx, cx
  199.     mov        al, CBIT
  200.     call    putbits_
  201.     $_do
  202.         mov        bl, [di]
  203.         inc        di
  204.         $_if <or bl, bl>, Z
  205.             xor        al, al
  206.             mov        cx, -1
  207.             repe    scasb
  208.             dec        di
  209.             not        cx
  210.             $_switch
  211.             $_case <cmp cx, 2>, BE
  212.                 $_do
  213.                     mov        al, pt_len_[0]
  214.                     mov        bx, pt_code_[0 * 2]
  215.                     call    putcode_
  216.                 $_until <LOOP>
  217.                 $_break
  218.             $_case <cmp cx, 19>, BE
  219.                 $_if , E
  220.                     mov        al, pt_len_[0]
  221.                     mov        bx, pt_code_[0 * 2]
  222.                     call    putcode_
  223.                     dec        cx
  224.                 $_endif
  225.                 mov        al, pt_len_[1]
  226.                 mov        bx, pt_code_[1 * 2]
  227.                 call    putcode_
  228.                 mov        al, 4
  229.                 mov        bx, cx
  230.                 sub        bx, 3
  231.                 call    putbits_
  232.                 $_break
  233.             $_default
  234.                 mov        al, pt_len_[2]
  235.                 mov        bx, pt_code_[2 * 2]
  236.                 call    putcode_
  237.                 mov        al, CBIT
  238.                 mov        bx, cx
  239.                 sub        bx, 20
  240.                 call    putbits_
  241.             $_endswitch
  242.         $_else
  243.             xor        bh, bh
  244.             mov        al, pt_len_[bx + 2]
  245.             shl        bx, 1
  246.             mov        bx, pt_code_[bx + 4]
  247.             call    putcode_
  248.         $_endif
  249.     $_until <cmp di, si>, A
  250.     pop        di
  251.     pop        si
  252.     pop        cx
  253.     ret
  254. write_c_len_    endp
  255.  
  256. ;
  257. ;    static void send_block(void)
  258. ;
  259.  
  260. ;public    send_block_
  261. send_block_    proc    near
  262.     push    cx
  263.     push    dx
  264.     push    si
  265.     push    di
  266.     push    bp
  267.  
  268.     mov        ax, NC
  269.     mov        bx, offset DGROUP:c_freq_
  270.     mov        cx, offset DGROUP:c_len_
  271.     mov        dx, offset DGROUP:c_code_
  272.     call    make_tree_
  273.     mov        bx, ax
  274.     mov        cx, ax
  275.     shl        bx, 1
  276.     mov        bx, c_freq_[bx]
  277.     mov        al, 16
  278.     call    putbits_
  279.     $_if <cmp cx, NC>, AE
  280.         call    count_t_freq_
  281.         mov        ax, NT
  282.         mov        bx, offset DGROUP:t_freq_
  283.         mov        cx, offset DGROUP:pt_len_
  284.         mov        dx, offset DGROUP:pt_code_
  285.         call    make_tree_
  286.         $_if <cmp ax, NT>, AE
  287.             mov        ax, NT
  288.             mov        bx, TBIT
  289.             mov        cx, 3
  290.             call    write_pt_len_
  291.         $_else
  292. if 1
  293.             mov        bx, ax
  294.             mov        al, TBIT * 2
  295.             call    putbits_
  296. else
  297.             mov        cx, ax
  298.             xor        bx, bx
  299.             mov        al, TBIT
  300.             call    putbits_
  301.             mov        bx, cx
  302.             mov        al, TBIT
  303.             call    putbits_
  304. endif
  305.         $_endif
  306.         call    write_c_len_
  307.     $_else
  308. if 1
  309.         xor        bx, bx
  310.         mov        al, CBIT + TBIT
  311.         call    putbits_
  312.         mov        bx, cx
  313.         mov        al, CBIT + TBIT
  314.         call    putbits_
  315. else
  316.         xor        bx, bx
  317.         mov        al, TBIT
  318.         call    putbits_
  319.         xor        bx, bx
  320.         mov        al, TBIT
  321.         call    putbits_
  322.         xor        bx, bx
  323.         mov        al, CBIT
  324.         call    putbits_
  325.         mov        bx, cx
  326.         mov        al, CBIT
  327.         call    putbits_
  328. endif
  329.     $_endif
  330.     mov        ax, NP
  331.     mov        bx, offset DGROUP:p_freq_
  332.     mov        cx, offset DGROUP:pt_len_
  333.     mov        dx, offset DGROUP:pt_code_
  334.     call    make_tree_
  335.     $_if <cmp ax, NP>, AE
  336.         mov        ax, NP
  337.         mov        bx, PBIT
  338.         mov        cx, -1
  339.         call    write_pt_len_
  340.     $_else
  341. if 1
  342.         mov        bx, ax
  343.         mov        al, PBIT * 2
  344.         call    putbits_
  345. else
  346.         mov        cx, ax
  347.         mov        al, PBIT
  348.         xor        bx, bx
  349.         call    putbits_
  350.         mov        al, PBIT
  351.         mov        bx, cx
  352.         call    putbits_
  353. endif
  354.     $_endif
  355.     les        si, buf_
  356.     xor        cx, cx
  357.     mov        bp, word ptr output_pos_
  358.     $_do
  359.         $_if <and cl, 07h>, Z
  360.             lods    byte ptr es:[si]
  361.             mov        ch, al
  362.         $_endif
  363.         xor        bh, bh
  364.         lods    byte ptr es:[si]
  365.         mov        bl, al
  366.         add        ch, 80h
  367.         rcl        bh, 1
  368.  
  369. ;    static void encode_c(short c)
  370.         mov        al, c_len_[bx]
  371.         shl        bx, 1
  372.         mov        bx, c_code_[bx]
  373.         call    putcode_
  374. ;
  375.         $_if <shl ch, 1>, NC
  376.             lods    word ptr es:[si]
  377.  
  378. ;    static void encode_p(ushort p)
  379.             mov        dx, ax
  380.             and        ax, 0000fh
  381.             mov        di, ax
  382.             mov        al, pt_len_[di]
  383.             shl        di, 1
  384.             mov        bx, pt_code_[di]
  385.             call    putcode_
  386.             shr        di, 1
  387.             $_if <dec di>, G
  388.                 mov        ax, di
  389.                 mov        bx, dx
  390.                 and        bl, 0f0h
  391.                 call    putcode_
  392.             $_endif
  393. ;
  394.  
  395.         $_endif
  396.         inc        cx
  397.     $_until <cmp si, bp>, AE
  398.     push    ds
  399.     pop        es
  400.     xor        ax, ax
  401.     mov        cx, NC
  402.     mov        di, offset DGROUP:c_freq_
  403.     rep        stosw
  404.     mov        cx, NP
  405.     mov        di, offset DGROUP:p_freq_
  406.     rep        stosw
  407.  
  408.     pop        bp
  409.     pop        di
  410.     pop        si
  411.     pop        dx
  412.     pop        cx
  413.     ret
  414. send_block_    endp
  415.  
  416. ;
  417. ;    void output_st1(ushort c, ushort p)
  418. ;
  419.  
  420. public    output_st1_
  421. output_st1_    proc    near
  422.     push    di
  423.     les        di, output_pos_
  424.     $_if <ror output_mask_, 1>, C
  425.         $_if <cmp di, buf_limit_>, AE
  426.             push    ax
  427.             push    bx
  428.             push    es
  429.             call    send_block_
  430.             pop        es
  431.             pop        bx
  432.             pop        ax
  433.             cmp        unpackable_, 0
  434.             jne        os1_end
  435.             xor        di, di
  436.         $_endif
  437.         mov        cpos_, di
  438.         mov        byte ptr es:[di], 0
  439.         inc        di
  440.     $_endif
  441.     stosb
  442.     xchg    bx, ax
  443.     shl        bx, 1
  444.     inc        c_freq_[bx]
  445.     $_if <shr bh, 1>, NZ
  446.  
  447.         xor        bx, bx
  448.         shl        ax, 1
  449.         jz        keta1
  450.         shl        ax, 1
  451.         shl        ax, 1
  452.         mov        bx, 13 + 1
  453.     keta0:
  454.         dec        bx
  455.         shl        ax, 1
  456.         jc        keta1
  457.         dec        bx
  458.         shl        ax, 1
  459.         jc        keta1
  460.         dec        bx
  461.         shl        ax, 1
  462.         jc        keta1
  463.         dec        bx
  464.         shl        ax, 1
  465.         jc        keta1
  466.         dec        bx
  467.         shl        ax, 1
  468.         jnc        keta0
  469.     keta1:
  470.  
  471.         or        ax, bx                    ; ì╢ïlé▀é╠ê╩Æu + îàÉö
  472.         stosw
  473.  
  474.         shl        bx, 1
  475.         inc        p_freq_[bx]
  476.  
  477.         mov        al, output_mask_
  478.         mov        bx, cpos_
  479.         or        es:[bx], al
  480.     $_endif
  481.     mov        word ptr output_pos_, di
  482. os1_end:
  483.     pop        di
  484.     ret
  485. output_st1_    endp
  486.  
  487. if 0
  488. ;
  489. ;    void far *alloc_buf(void)
  490. ;
  491.  
  492. public    alloc_buf_
  493. alloc_buf_    proc    near
  494.     mov        bx, 0ffffh
  495.     mov        ah, 48h
  496.     int        21h
  497.     $_if <cmp bx, 256>, AE
  498.         mov        ax, 1024
  499.         $_if <cmp bx, ax>, B
  500.             mov        ax, bx
  501.         $_endif
  502.         mov        bx, ax
  503.         shl        ax, 1
  504.         shl        ax, 1
  505.         shl        ax, 1
  506.         shl        ax, 1
  507.         sub        ax, 24
  508.         mov        buf_limit_, ax
  509.         mov        ah, 48h
  510.         int        21h
  511.         mov        bx, ax
  512.     $_else
  513.         xor        bx, bx
  514.     $_endif
  515.     xor        ax, ax
  516.     mov        word ptr buf_ + 2, bx
  517.     mov        word ptr buf_, ax
  518.     ret
  519. alloc_buf_    endp
  520. endif
  521.  
  522. ;
  523. ;    void encode_start_st1(void)
  524. ;
  525.  
  526. public    encode_start_st1_
  527. encode_start_st1_    proc    near
  528.     push    cx
  529.     push    di
  530.     push    ds
  531.     pop        es
  532.     xor        ax, ax
  533.     mov        cx, NC
  534.     mov        di, offset DGROUP:c_freq_
  535.     rep        stosw
  536.     mov        cx, NP
  537.     mov        di, offset DGROUP:p_freq_
  538.     rep        stosw
  539.     les        bx, buf_
  540.     mov        word ptr output_pos_ + 2, es
  541.     mov        word ptr output_pos_, bx
  542.     mov        byte ptr es:[bx], 0
  543.     mov        output_mask_, 01h
  544.     call    init_putbits_
  545.     pop        di
  546.     pop        cx
  547.     ret
  548. encode_start_st1_    endp
  549.  
  550. ;
  551. ;    void encode_end_st1(void)
  552. ;
  553.  
  554. public    encode_end_st1_
  555. encode_end_st1_    proc    near
  556.     $_if <cmp unpackable_, 0>, E
  557.         call    send_block_
  558.         mov        ax, 7
  559.         xor        bx, bx
  560.         call    putcode_
  561.     $_endif
  562.     ret
  563. encode_end_st1_    endp
  564.  
  565. ;    /***** decoding *****/
  566.  
  567. ;
  568. ;    static void read_pt_len(short nn, short nbit, short i_special)
  569. ;
  570.  
  571. ;public    read_pt_len_
  572. read_pt_len_    proc    near
  573.     push    cx
  574.     push    dx
  575.     push    si
  576.     push    di
  577.  
  578.     push    ax
  579.     mov        si, ax
  580.     mov        dx, bx
  581.     mov        ax, bx
  582.     call    getbits_
  583.     cmp        ax, si
  584.     ja        tbl_error_
  585.  
  586.     mov        di, offset DGROUP:pt_len_
  587.     $_if <or ax, ax>, Z
  588.         mov        di, offset DGROUP:pt_len_
  589.         pop        cx
  590.         rep        stosb
  591.         mov        ax, dx
  592.         call    getbits_
  593.         mov        cx, 256
  594.         mov        di, offset DGROUP:pt_table_
  595.         rep        stosw
  596.     $_else
  597.         mov        dx, cx            ; dl = i_special
  598.         add        dx, di
  599.         mov        si, di
  600.         add        si, ax            ; ax = n
  601.         $_do
  602.             mov        ax, 3
  603.             call    getbits_
  604.             $_if <cmp al, 7>, E
  605.                 mov        bx, bitbuf_
  606.                 $_while <shl bx, 1>, C
  607.                     inc        ax
  608.                 $_enddo
  609.                 push    ax
  610.                 sub        ax, 6
  611.                 call    fillbuf_
  612.                 pop        ax
  613.             $_endif
  614.             stosb
  615.             $_if <cmp di, dx>, E
  616.                 mov        ax, 2
  617.                 call    getbits_
  618.                 mov        cx, ax
  619.                 xor        al, al
  620.                 rep        stosb
  621.             $_endif
  622.         $_until <cmp di, si>, AE
  623.         pop        cx                        ; nn
  624.         mov        si, cx
  625.         add        cx, offset DGROUP:pt_len_
  626.         sub        cx, di
  627.         jb        tbl_error_
  628.         xor        al, al
  629.         rep        stosb
  630.         mov        ax, si
  631.         mov        bx, offset DGROUP:pt_len_
  632.         mov        cx, 8
  633.         mov        dx, offset DGROUP:pt_table_
  634.         call    make_table_
  635.     $_endif
  636.  
  637.     pop        di
  638.     pop        si
  639.     pop        dx
  640.     pop        cx
  641.     ret
  642. read_pt_len_    endp
  643.  
  644. extrn    error_:near
  645. extrn    BROKENARC_:byte
  646.  
  647. tbl_error_    proc    near
  648.     mov        ax, offset DGROUP:BROKENARC_
  649.     xor        bx, bx
  650.     jmp        error_
  651. tbl_error_    endp
  652.  
  653. ;
  654. ;    static void read_c_len(void)
  655. ;
  656.  
  657. ;public    read_c_len_
  658. read_c_len_    proc    near
  659.     push    cx
  660.     push    dx
  661.     push    di
  662.  
  663.     mov        ax, CBIT
  664.     call    getbits_
  665.     cmp        ax, NC
  666.     ja        tbl_error_
  667.  
  668.     mov        di, offset DGROUP:c_len_
  669.     $_if <or ax, ax>, Z
  670.         mov        cx, NC
  671.         rep        stosb
  672.         mov        ax, CBIT
  673.         call    getbits_
  674.         mov        cx, 4096
  675.         mov        di, offset DGROUP:c_table_
  676.         rep        stosw
  677.     $_else
  678.         mov        dx, di
  679.         add        dx, ax            ; ax = n
  680.         $_do
  681.             mov        ax, bitbuf_
  682.             mov        bl, ah
  683.             xor        bh, bh
  684.             shl        bx, 1
  685.             mov        bx, pt_table_[bx]
  686.             $_while <cmp bx, NT>, AE
  687.                 $_if <shl al, 1>, C
  688.                     mov        bx, right_[bx]
  689.                 $_else
  690.                     mov        bx, left_[bx]
  691.                 $_endif
  692.             $_enddo
  693.             push    bx
  694.             mov        al, pt_len_[bx]
  695.             call    fillbuf_
  696.             pop        ax
  697.             $_if <sub ax, 2>, BE
  698.                 $_if , Z
  699.                     mov        ax, CBIT
  700.                     call    getbits_
  701.                     add        ax, 20
  702.                     mov        cx, ax
  703.                 $_else
  704.                     $_if <inc ax>, Z
  705.                         mov        ax, 4
  706.                         call    getbits_
  707.                         add        ax, 3
  708.                         mov        cx, ax
  709.                     $_else
  710.                         mov        cx, 1
  711.                     $_endif
  712.                 $_endif
  713.                 xor        al, al
  714.                 rep        stosb
  715.             $_else
  716.                 stosb
  717.             $_endif
  718.         $_until <cmp di, dx>, AE
  719.         mov        cx, offset DGROUP:c_len_ + NC
  720.         sub        cx, di
  721.         jb        tbl_error_
  722.         xor        al, al
  723.         rep        stosb
  724.         mov        ax, NC
  725.         mov        bx, offset DGROUP:c_len_
  726.         mov        cx, 12
  727.         mov        dx, offset DGROUP:c_table_
  728.         call    make_table_
  729.     $_endif
  730.     pop        di
  731.     pop        dx
  732.     pop        cx
  733.     ret
  734. read_c_len_    endp
  735.  
  736. ;
  737. ;    ushort decode_c_st1(void)
  738. ;
  739.  
  740. decode_c    proc    near
  741. ;    not entry here
  742. decode_c_st1_2:
  743.     push    ax
  744.     push    bx
  745.     push    cx
  746.     mov        ax, 16
  747.     call    getbits_
  748.     dec        ax
  749.     mov        blocksize_, ax
  750.     mov        ax, NT
  751.     mov        bx, TBIT
  752.     mov        cx, 3
  753.     call    read_pt_len_
  754.     call    read_c_len_
  755.     mov        ax, NP
  756.     mov        bx, PBIT
  757.     mov        cx, -1
  758.     call    read_pt_len_
  759.     pop        cx
  760.     pop        bx
  761.     pop        ax
  762.     jmp        decode_c_st1_3
  763. ;
  764. ;    entry here
  765. ;
  766. public    decode_c_st1_
  767. decode_c_st1_:
  768.     push    cx
  769.     sub        blocksize_, 1
  770.     jc        decode_c_st1_2
  771. decode_c_st1_3:
  772.     mov        bx, bitbuf_
  773.     mov        cl, 4
  774.     shr        bx, cl
  775.     shl        bx, 1
  776.     mov        bx, c_table_[bx]
  777.     $_if    <cmp bx, NC>, B
  778. decode_c_st1_1:
  779.         push    bx
  780.         mov        al, c_len_[bx]
  781.         call    fillbuf_
  782.         pop        ax
  783.         pop        cx
  784.         ret
  785.     $_endif
  786.     mov        ax, bitbuf_
  787.     shl        al, cl
  788.     $_do
  789.         $_if <shl al, 1>, C
  790.             mov        bx, right_[bx]
  791.         $_else
  792.             mov        bx, left_[bx]
  793.         $_endif
  794.     $_until <cmp bx, NC>, B
  795.     jmp        decode_c_st1_1
  796. decode_c    endp
  797.  
  798. ;
  799. ;    ushort decode_p_st1(void)
  800. ;
  801.  
  802. public    decode_p_st1_
  803. decode_p_st1_    proc    near
  804.     push    cx
  805.     xor        bh, bh
  806.     mov        bl, byte ptr bitbuf_ + 1
  807.     shl        bx, 1
  808.     mov        bx, pt_table_[bx]
  809.     $_if    <cmp bx, NP>, B
  810. decode_p_st1_1:
  811.         push    bx
  812.         mov        al, pt_len_[bx]
  813.         call    fillbuf_
  814.         pop        ax
  815.         $_if <or ax, ax>, NZ
  816.             dec        ax
  817.             mov        cx, ax
  818.             call    getbits_
  819.             mov        bx, 1
  820.             shl        bx, cl
  821.             or        ax, bx
  822.         $_endif
  823.         pop        cx
  824.         ret
  825.     $_endif
  826.     mov        al, byte ptr bitbuf_
  827.     $_do
  828.         $_if <shl al, 1>, C
  829.             mov        bx, right_[bx]
  830.         $_else
  831.             mov        bx, left_[bx]
  832.         $_endif
  833.     $_until <cmp bx, NP>, B
  834.     jmp        decode_p_st1_1
  835. decode_p_st1_    endp
  836.  
  837. ;
  838. ;    void decode_start_st1(void)
  839. ;
  840.  
  841. public    decode_start_st1_
  842. decode_start_st1_    proc    near
  843.     mov        blocksize_, 0
  844.     jmp        init_getbits_
  845. decode_start_st1_    endp
  846.  
  847. TEXT    ends
  848.         end
  849.